<?php

	// +----------------------------------------------------------------------
	// | 权限分组模型
	// +----------------------------------------------------------------------
	// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
	// +----------------------------------------------------------------------
	// | Author: 微尘 <yicmf@qq.com>
	// +----------------------------------------------------------------------

	namespace app\model\ucenter;

	class UserToken extends Common
	{

		public function user()
		{
			return $this->belongsTo(User::class);
		}

		/**
		 * 写入修改
		 */
		public static function onBeforeWrite($data)
		{
			$data['times'] = 1;
			$data['status'] = 1;
//			$data['os'] = self::$request->server('HTTP_USER_AGENT');
			$data['ip'] = self::$request->ip();
			$data['expire_time'] = time_format('10 day');
			$data['token'] = md5(uniqid());
		}
	}
